﻿''' <summary>
''' The framework object class.
''' </summary>
''' <remarks></remarks>
Public Class FrameworkObjects

#Region "**Enums**"
    ''' <summary>Enum for the types of recurrence patterns.</summary>
    Public Enum RecurrenceTypes
        ''' <summary>Recurs daily based on Frequency.</summary>
        Daily = 0
        ''' <summary>Recurs weekly based on the DaysOfWeek and Frequency.</summary>
        Weekly = 1
        ''' <summary>Recurs monthly based on the Frequency.</summary>
        Monthly = 2
        ''' <summary>Allows the developer to add a collection of dates to the Recurrence object and use those accordingly.</summary>
        Custom = 3
    End Enum

    ''' <summary>Enum to indicate the type of object to use the Recurrence on.</summary>
    Public Enum RecurrenceObjectType
        ''' <summary>Use the Recurrence object with loading dock exceptions.</summary>
        DockException = 0
        ''' <summary>Use the Recurrence object for shipments.</summary>
        Shipment = 1
    End Enum

    ''' <summary>Enum to indicate if a shipment is inbound or outbound</summary>
    Public Enum ShipmentTypes
        ''' <summary>The shipment is inbound</summary>
        Inbound = 0
        ''' <summary>The shipment is outbound</summary>
        Outbound = 1
    End Enum
#End Region

#Region "**Default Property Constants**"

    'These are the default values used when creating new objects, you can change these
    'or be sure to set the properties explicitly in your main application.

#Region "--objWarehouse--"
    Private Const WarehouseDescription As String = "New Warehouse"
    Private Const WarehouseLocation As String = "New Location"
    Private Const WarehouseNotes As String = ""
#End Region

#Region "--objLoadingDock--"
    Private Const LoadingDockDescription As String = "New LoadingDock"
    Private Const LoadingDockWarehouseOrdinal As Long = 0
    Private Const LoadingDockNotes As String = ""
#End Region

#Region "--objShipment--"
    Private Const ShipmentDescription As String = ""
    Private Const ShipmentType As ShipmentTypes = ShipmentTypes.Outbound
    Private Const ShipmentBreakoutQty As Long = 0
    Private Const ShipmentEquipmentID As String = ""
    Private Const ShipmentCarrierID As String = ""
    Private Const ShipmentPriority As Integer = 0
    Private Const ShipmentNotes As String = ""

#End Region

#Region "--objOrderHeader--"
    Private Const OrderHeaderEntryID As String = "POS OrderID"
    Private Const OrderHeaderEntryType As String = "Packing Slip"
    Private Const OrderHeaderVendorID As String = "" 'POS/Integrated VendorID
    Private Const OrderHeaderCustomerID As String = "" 'POS/Integrated CustomerID
    Private Const OrderHeaderNotes As String = ""
#End Region

#Region "--objOrderDetail--"
    Private Const OrderDetailLineNumber = 0 'POS/Intgrated Line Number
    Private Const OrderDetailUnitWeight As String = ""
    Private Const OrderDetailUnitOfMeasure As String = ""
    Private Const OrderDetailUnitVolume As String = ""
    Private Const OrderDetailQuantity As Double = 1
    Private Const OrderDetailNotes As String = ""
#End Region

#Region "--objRecurrence--"
    Private Const RecurrenceType As RecurrenceObjectType = RecurrenceObjectType.DockException
    Private Const RecurrenceDescription As String = "New Recurrence"
    Private Const RecurrenceNotes As String = ""
#End Region

#Region "--objLoadingDockExceptions--"
    Private Const LDEDescription As String = "New Loading Dock Exception"
    Private Const LDENotes As String = ""
#End Region

#Region "--objCargoTypes--"
    Private Const CargoTypeDescription As String = "New Cargo Type"
    Private Const CargoTypeNotes As String = ""

#End Region

#End Region

#Region "**Object Class References**"

#Region "++Object Layout Template++"
    '    ObjName

    '-Local Variables

    '-Public Properties (Base ID – Type System.Guid)
    '-Public Properties (Base Types not including collections)
    '-Public Properties (Collection Based Items)
    '-Public AttachedDatarow Property
    '-Public Tag Object (be sure to document the fact that the database class won’t update this property)
    '-Public Notes Property

    '-Method – New (Base and overloads)

    '-Method – AddNew (method for adding items to parent collections and updating databases)
    '-Method – Remove (removes from collections and databases)
    '-Method – Other Public Methods

    '-Private Methods and Functions

#End Region

#Region "--Main Objects--"
    ''' <summary> Contains collections of the unique WSF objects that can be globally referenced throughout an application.</summary>
    Public Class objWSFObjects
        Private l_WSFDatabinding As dbiWSF.Databinding
        Private l_WarehouseCollection As New System.Collections.Generic.List(Of objWarehouse)
        Private l_CargoTypeCollection As New System.Collections.Generic.SortedList(Of String, objCargoType)
        Private l_RecurrenceCollection As New System.Collections.Generic.List(Of objRecurrence)
        Private l_LoadingDockExceptionCollection As New System.Collections.Generic.List(Of objLoadingDockException)
        Private l_LoadDateStart As Date
        Private l_LoadDateEnd As Date

        ''' <summary>The main databinding class for use with the rest of the Framework</summary>
        Public Property WSFDatabinding() As dbiWSF.Databinding
            Get
                Return l_WSFDatabinding
            End Get
            Set(ByVal value As dbiWSF.Databinding)
                l_WSFDatabinding = value
            End Set
        End Property

        ''' <summary>
        ''' Used to store a collection containing the warehouses.
        ''' Each warehouse in the collection serves as a parent container for the Main WSF objects.
        ''' </summary>
        Public Property Warehouses() As System.Collections.Generic.List(Of objWarehouse)
            Get
                Return l_WarehouseCollection
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of objWarehouse))
                l_WarehouseCollection = value
            End Set
        End Property

        ''' <summary>
        ''' Used to store a collection containing all the Recurring objects attached to the WSF.
        ''' </summary>
        Public Property Recurrences() As System.Collections.Generic.List(Of objRecurrence)
            Get
                Return l_RecurrenceCollection
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of objRecurrence))
                l_RecurrenceCollection = value
            End Set
        End Property

        ''' <summary>
        ''' Used to store a collection containing all the available cargo types that are
        ''' attached to the individual OrderHeaders.
        ''' </summary>
        Public Property CargoTypes() As System.Collections.Generic.SortedList(Of String, objCargoType)
            Get
                Return l_CargoTypeCollection
            End Get
            Set(ByVal value As System.Collections.Generic.SortedList(Of String, objCargoType))
                l_CargoTypeCollection = value
            End Set
        End Property

        ''' <summary>
        ''' Used to store a collection containing all the loading dock exceptions.
        ''' </summary>
        ''' <remarks>
        ''' Because LoadingDockExceptions can apply to multiple loading docks, the exception collection
        ''' is housed outside of the individual loading docks and managed through the ExceptionDockKeys
        ''' DataAdapter and DataTable.
        ''' </remarks>
        Public Property LoadingDockExceptions() As System.Collections.Generic.List(Of objLoadingDockException)
            Get
                Return l_LoadingDockExceptionCollection
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of objLoadingDockException))
                l_LoadingDockExceptionCollection = value
            End Set
        End Property

        ''' <summary>ReadOnly property indicating the start datetime of the dataload</summary>
        Public ReadOnly Property LoadDateStart() As Date
            Get
                Return l_LoadDateStart
            End Get
        End Property

        ''' <summary>ReadOnly property indicating the end datetime of the dataload</summary>
        Public ReadOnly Property LoadDateEnd() As Date
            Get
                Return l_LoadDateEnd
            End Get
        End Property

        ''' <summary>
        ''' Returns a collection of dates/times where the Recurrence object will fall given 
        ''' the Recurrence Type, the start and end periods and the frequency to recur.
        ''' </summary>
        ''' <param name="startDate">The date with which to start the calculations</param>
        ''' <param name="enddate">The date to end the calculations on</param>
        ''' <param name="freq">The frequency with which the pattern will recur</param>
        ''' <param name="SelectedDates">The DaysOfTheWeek on which these will recur. Only applicable to Weekly Recurrence Types.
        ''' </param>
        ''' <returns>Collection of Dates</returns>
        ''' <remarks>The SelectedDates parameter will accept an array of bytes indicating the weekdays to recur on. {1,4,6} will 
        ''' indicate the first, fourth and sixth days of the week based on the globalization settings for the
        ''' current O/S.</remarks>
        Public Function FixedDates(ByVal startDate As Date, ByVal enddate As Date, ByVal freq As Integer, ByVal SelectedDates() As Byte) As System.Collections.Generic.List(Of Date)
            Dim DatesCollection As New Collections.Generic.List(Of Date)

            Dim curDate As Date = startDate
            Dim curLoop As Integer = 0
            While curDate < enddate
                curDate = startDate.AddDays(freq * 7 * curLoop)
                For dateTest As Integer = 0 To 6
                    If SelectedDates.Contains(curDate.AddDays(dateTest).DayOfWeek) And curDate.AddDays(dateTest) <= enddate Then
                        DatesCollection.Add(curDate.AddDays(dateTest).Date)
                    End If
                Next
                curLoop += 1
            End While
            Return DatesCollection
        End Function

        ''' <summary>
        ''' Transfers a shipment from a loading dock shipment collection to another one.
        ''' </summary>
        ''' <param name="curShipment">The shipment object to transfer</param>
        ''' <param name="OrigLoadingDockID">The original LoadingDockID GUID</param>
        ''' <param name="NewLoadingDockID">The new LoadingDockID GUID</param>
        ''' <remarks></remarks>
        Public Sub collectionTransferShipment(ByRef curShipment As dbiWSF.FrameworkObjects.objShipment, ByVal OrigLoadingDockID As System.Guid, ByVal NewLoadingDockID As System.Guid)
            Try

                Dim OrigLoadingDockQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                               From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                               Where LoadingDock.LoadingDockID = OrigLoadingDockID _
                               Select LoadingDock

                Dim NewLoadingDockQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                               From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                               Where LoadingDock.LoadingDockID = NewLoadingDockID _
                               Select LoadingDock


                If OrigLoadingDockQuery.Count > 0 And NewLoadingDockQuery.Count > 0 Then
                    OrigLoadingDockQuery(0).Shipments.Remove(curShipment)
                    NewLoadingDockQuery(0).Shipments.Add(curShipment)
                End If

            Catch ex As Exception
                Throw New Exception("Item not found in loadingdock.shipment collections", ex)
            End Try
        End Sub

        ''' <summary>
        ''' Transfers a loading dock from a warehouse loading dock collection to another one.
        ''' </summary>
        ''' <param name="curLoadingDock">The LoadingDock object to transfer</param>
        ''' <param name="origWarehouseID">The original WarehouseID GUID</param>
        ''' <param name="newWarehouseID">The new WarehouseID GUID</param>
        ''' <remarks></remarks>
        Public Sub collectionTransferLoadingDock(ByRef curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock, ByVal origWarehouseID As System.Guid, ByVal newWarehouseID As System.Guid)
            Try

                Dim origWarehouseQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                                         Where Warehouse.WarehouseID = origWarehouseID _
                                         Select Warehouse


                Dim newWarehouseQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                                        Where Warehouse.WarehouseID = newWarehouseID _
                                        Select Warehouse

                If origWarehouseQuery.Count > 0 And newWarehouseQuery.Count > 0 Then
                    origWarehouseQuery(0).LoadingDocks.Remove(curLoadingDock)
                    newWarehouseQuery(0).LoadingDocks.Add(curLoadingDock)
                End If

            Catch ex As Exception
                Throw New Exception("Item not found in Warehouse.LoadingDock collections", ex)
            End Try
        End Sub

        ''' <summary>
        ''' Transfer an OrderHeader from one Shipment collection to another.
        ''' </summary>
        ''' <param name="curOrderHeader">The OrderHeader to transfer</param>
        ''' <param name="OrigShipmentID">The original ShipmentID GUID</param>
        ''' <param name="NewShipmentID">The new ShipmentID GUID</param>
        ''' <remarks></remarks>
        Public Sub collectionTransferOrderHeader(ByRef curOrderHeader As dbiWSF.FrameworkObjects.objOrderHeader, ByVal OrigShipmentID As System.Guid, ByVal NewShipmentID As System.Guid)
            Try

                Dim OrigShipmentQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                               From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                               From Shipment As dbiWSF.FrameworkObjects.objShipment In LoadingDock.Shipments _
                               Where Shipment.ShipmentID = OrigShipmentID _
                               Select Shipment

                Dim NewShipmentQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Warehouses _
                               From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                               From Shipment As dbiWSF.FrameworkObjects.objShipment In LoadingDock.Shipments _
                               Where Shipment.ShipmentID = NewShipmentID _
                               Select Shipment


                If OrigShipmentQuery.Count > 0 And NewShipmentQuery.Count > 0 Then
                    OrigShipmentQuery(0).OrderHeaders.Remove(curOrderHeader)
                    NewShipmentQuery(0).OrderHeaders.Add(curOrderHeader)
                End If

            Catch ex As Exception
                Throw New Exception("Item not found in Shipment.OrderHeaders collections", ex)
            End Try
        End Sub

        ''' <summary>
        ''' Creates a new instance of the class with a default databinding object attached.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
            Me.WSFDatabinding = New dbiWSF.Databinding
            Me.WSFDatabinding.WSFObjects = Me
        End Sub

        ''' <summary>
        ''' Creates a new instance of the class with a specified databinding object attached.
        ''' </summary>
        ''' <param name="curDatabinding">A databinding object to use to coordinate data with the object class</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal curDatabinding As dbiWSF.Databinding)
            Me.WSFDatabinding = curDatabinding
            Me.WSFDatabinding.WSFObjects = Me
        End Sub

        ''' <summary>
        ''' Creates a new instance of the class with a new databinding object attached defined by the parameters provided.
        ''' </summary>
        ''' <param name="DataConnectionType">The databinding connection type to create</param>
        ''' <param name="DataBindingMethod">The type of databinding method to use</param>
        ''' <param name="connectionString">The connection string used to connect to an ADO dataset</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal DataConnectionType As dbiWSF.Databinding.ConnectionTypes, ByVal DataBindingMethod As dbiWSF.Databinding.DataBindingMethods, ByVal connectionString As String)
            Dim newDatabinding As New dbiWSF.Databinding
            newDatabinding.ConnectionType = DataConnectionType
            newDatabinding.DataBindingMethod = DataBindingMethod
            newDatabinding.ConnectionString = connectionString
            Me.WSFDatabinding = newDatabinding
            Me.WSFDatabinding.WSFObjects = Me
        End Sub

        ''' <summary>
        ''' The method used to fill the objects with data from the databinding object.
        ''' </summary>
        ''' <param name="StartDateTime">Optional: The start date time of the shipment data to load</param>
        ''' <param name="EndDateTime">Optional: The end date time of the shipment data to load</param>
        ''' <remarks>You can modify this method to enable/disable table loading on individual tables
        ''' This is only coded for InMemory data binding</remarks>
        Public Sub LoadAllData(Optional ByVal StartDateTime As Date = Nothing, Optional ByVal EndDateTime As Date = Nothing)
            Try
                If Me.WSFDatabinding.ConnectionString <> "" Then
                    '<Modify> If you want to remove individual tables from loading
                    LoadCargoTypes()
                    LoadExceptions()
                    LoadRecurrences()

                    Me.Warehouses = WSFDatabinding.LoadAllData(StartDateTime, EndDateTime)

                    Try
                        If StartDateTime = Nothing Then
                            Dim GetDateStartTime = From Warehouse As objWarehouse In Me.Warehouses _
                                                   From LoadingDock As objLoadingDock In Warehouse.LoadingDocks _
                                                   From Shipment As objShipment In LoadingDock.Shipments _
                                                   Select Shipment.SchedStartTime

                            Me.l_LoadDateStart = GetDateStartTime.Min
                        Else
                            Me.l_LoadDateStart = StartDateTime
                        End If
                    Catch ex As Exception
                        'No records found and no startdatetime passed in, set default of today
                        Me.l_LoadDateStart = Today
                    End Try
                    Try
                        If EndDateTime = Nothing Then
                            Dim GetDateEndTime = From Warehouse As objWarehouse In Me.Warehouses _
                                                  From LoadingDock As objLoadingDock In Warehouse.LoadingDocks _
                                                  From Shipment As objShipment In LoadingDock.Shipments _
                                                  Select Shipment.SchedEndTime
                            Me.l_LoadDateEnd = GetDateEndTime.Max
                        Else
                            Me.l_LoadDateEnd = EndDateTime
                        End If
                    Catch ex As Exception
                        'No records found and no startdatetime passed in, set default of one week from today
                        Me.l_LoadDateStart = Today.AddDays(7)
                    End Try

                Else
                    Throw New Exception("No databinding set") '<Generic Error>
                End If
            Catch ex As Exception
                Throw New Exception("Error in LoadAllData", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>This method is used to load the recurrences information.</summary>
        Public Sub LoadRecurrences()
            Me.Recurrences = WSFDatabinding.LoadRecurrenceExceptions
        End Sub

        ''' <summary>This method is used to load the exception information.</summary>
        Public Sub LoadExceptions()
            Me.LoadingDockExceptions = WSFDatabinding.LoadLoadingDockExceptions
        End Sub

        ''' <summary>This method is used to load the cargo types information.</summary>
        Public Sub LoadCargoTypes()
            Me.CargoTypes = WSFDatabinding.LoadCargoTypes
        End Sub

        ''' <summary>
        ''' Get a warehouse object given the ID GUID
        ''' </summary>
        ''' <param name="WarehouseID">The WarehouseID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetWarehouseFromGUID(ByVal WarehouseID As System.Guid) As dbiWSF.FrameworkObjects.objWarehouse
            Dim curWarehouse As dbiWSF.FrameworkObjects.objWarehouse

            Dim WarehouseQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Me.Warehouses _
                                 Where Warehouse.WarehouseID = WarehouseID _
                                 Select Warehouse

            curWarehouse = WarehouseQuery(0)

            Return curWarehouse
        End Function

        ''' <summary>
        ''' Get a loading dock object given the ID GUID
        ''' </summary>
        ''' <param name="LoadingDockID">The LoadingDockID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetLoadingDockFromGUID(ByVal LoadingDockID As System.Guid) As dbiWSF.FrameworkObjects.objLoadingDock
            Dim curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock

            Dim LoadingDockQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Me.Warehouses _
                                   From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                                   Where LoadingDock.LoadingDockID = LoadingDockID _
                                   Select LoadingDock

            curLoadingDock = LoadingDockQuery(0)

            Return curLoadingDock
        End Function

        ''' <summary>
        ''' Get a shipment object given the ID GUID
        ''' </summary>
        ''' <param name="ShipmentID">The ShipmentID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetShipmentFromGUID(ByVal ShipmentID As System.Guid) As dbiWSF.FrameworkObjects.objShipment
            Dim curShipment As dbiWSF.FrameworkObjects.objShipment
            Dim ShipmentQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Me.Warehouses _
                                   From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                                   From Shipment As dbiWSF.FrameworkObjects.objShipment In LoadingDock.Shipments _
                                   Where Shipment.ShipmentID = ShipmentID _
                                   Select Shipment

            curShipment = ShipmentQuery(0)
            Return curShipment
        End Function

        ''' <summary>
        ''' Get a Cargo object given the ID GUID
        ''' </summary>
        ''' <param name="CargoTypeID">The CargoTypeID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetCargoFromGUID(ByVal CargoTypeID As System.Guid) As dbiWSF.FrameworkObjects.objCargoType
            Dim curCargo As dbiWSF.FrameworkObjects.objCargoType
            Dim CargoQuery = From CargoType As KeyValuePair(Of String, dbiWSF.FrameworkObjects.objCargoType) In Me.CargoTypes _
                             Where CargoType.Value.CargoID = CargoTypeID _
                             Select CargoType
            curCargo = CargoQuery(0).Value
            Return curCargo
        End Function

        ''' <summary>
        ''' Get an OrderHeader object given the ID GUID
        ''' </summary>
        ''' <param name="OrderHeaderID">The OrderID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetOrderHeaderFromGUID(ByVal OrderHeaderID As System.Guid) As dbiWSF.FrameworkObjects.objOrderHeader
            Dim curOrderHeader As dbiWSF.FrameworkObjects.objOrderHeader
            Dim OrderHeaderQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Me.Warehouses _
                                   From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                                   From Shipment As dbiWSF.FrameworkObjects.objShipment In LoadingDock.Shipments _
                                   From OrderHeader As dbiWSF.FrameworkObjects.objOrderHeader In Shipment.OrderHeaders _
                                   Where OrderHeader.OrderID = OrderHeaderID _
                                   Select OrderHeader

            curOrderHeader = OrderHeaderQuery(0)
            Return curOrderHeader
        End Function

        ''' <summary>
        ''' Get an OrderDetail object given the ID GUID
        ''' </summary>
        ''' <param name="OrderDetailID">The OrderDetailID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetOrderDetailFromGUID(ByVal OrderDetailID As System.Guid) As dbiWSF.FrameworkObjects.objOrderDetail
            Dim curOrderdetail As dbiWSF.FrameworkObjects.objOrderDetail
            Dim OrderDetailQuery = From Warehouse As dbiWSF.FrameworkObjects.objWarehouse In Me.Warehouses _
                                   From LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Warehouse.LoadingDocks _
                                   From Shipment As dbiWSF.FrameworkObjects.objShipment In LoadingDock.Shipments _
                                   From OrderHeader As dbiWSF.FrameworkObjects.objOrderHeader In Shipment.OrderHeaders _
                                   From OrderDetail As dbiWSF.FrameworkObjects.objOrderDetail In OrderHeader.OrderDetails _
                                   Where OrderDetail.OrderDetailID = OrderDetailID _
                                   Select OrderDetail

            curOrderdetail = OrderDetailQuery(0)
            Return curOrderdetail
        End Function

        ''' <summary>
        ''' Gets the LoadingDockException object given the ID GUID 
        ''' </summary>
        ''' <param name="LDExceptionID">The loadingdockexception ID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetLoadingDockExceptionFromGUID(ByVal LDExceptionID As System.Guid) As dbiWSF.FrameworkObjects.objLoadingDockException
            Dim curLDException As dbiWSF.FrameworkObjects.objLoadingDockException
            Dim LDExceptionQuery = From LDExceptions As dbiWSF.FrameworkObjects.objLoadingDockException In Me.LoadingDockExceptions _
                                   Where LDExceptions.LoadingDockExceptionID = LDExceptionID _
                                   Select LDExceptions

            curLDException = LDExceptionQuery(0)
            Return curLDException
        End Function

        ''' <summary>
        ''' Gets the Recurrence object given the ID GUID 
        ''' </summary>
        ''' <param name="RecurrenceID">The Recurrence ID GUID</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function GetRecurrenceFromGUID(ByVal RecurrenceID As System.Guid) As dbiWSF.FrameworkObjects.objRecurrence
            Dim curRecurrence As dbiWSF.FrameworkObjects.objRecurrence
            Dim RecurrenceQuery = From Recurrence As dbiWSF.FrameworkObjects.objRecurrence In Me.Recurrences _
                                   Where Recurrence.RecurrenceID = RecurrenceID _
                                   Select Recurrence

            curRecurrence = RecurrenceQuery(0)
            Return curRecurrence
        End Function

        ''' <summary>
        ''' Gets the Cargo.Description from the CargoTypes collection based on the CargoTypeID GUID.
        ''' </summary>
        ''' <param name="curCargoID">The GUID for the Cargo object.</param>
        ''' <returns>String</returns>
        ''' <remarks>
        ''' This function is used to assist in cross-application integration with 
        ''' existing systems.
        ''' </remarks>
        Public Function GetCargoDescripFromID(ByVal curCargoID As System.Guid) As String
            Dim cargoID As String = ""
            For Each curCargo As KeyValuePair(Of String, dbiWSF.FrameworkObjects.objCargoType) In CargoTypes
                If curCargo.Value.CargoID = curCargoID Then
                    cargoID = curCargo.Value.Description
                    Exit For
                End If
            Next
            Return cargoID
        End Function

        ''' <summary>Supporting Method: Gets all unassigned shipments.</summary>
        ''' <returns>Collection of objShipment</returns>
        Public Function GetUnassignedShipments() As Collections.Generic.List(Of dbiWSF.FrameworkObjects.objShipment)
            Return WSFDatabinding.GetUnassignedShipments()
        End Function

        ''' <summary>Supporting Method: Gets all unassigned OrderHeaders.</summary>
        ''' <returns>Collection of objOrderHeader</returns>
        Public Function GetUnassignedOrderHeaders() As Collections.Generic.List(Of dbiWSF.FrameworkObjects.objOrderHeader)
            Return WSFDatabinding.GetUnassignedOrderHeaders
        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptions(ByVal collDates As System.Collections.Generic.List(Of Date)) _
                                            As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim collGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each DateToCheck As Date In collDates
                For Each recurrence As dbiWSF.FrameworkObjects.objRecurrence In Me.Recurrences
                    If recurrence.GetRecurrenceDates.Contains(DateToCheck) Then
                        If recurrence.ObjectType = RecurrenceObjectType.DockException Then
                            For Each loadingdock As System.Guid In recurrence.RecurringObjects
                                Dim newGenericException As New dbiWSF.FrameworkObjects.objGenericException
                                newGenericException.DateStart = DateToCheck.AddMilliseconds(recurrence.ObjectStartDate.TimeOfDay.TotalMilliseconds)
                                newGenericException.DateEnd = newGenericException.DateStart.AddSeconds(DateDiff(DateInterval.Second, recurrence.ObjectStartDate, recurrence.ObjectEndDate))
                                newGenericException.Description = recurrence.Description
                                newGenericException.objLoadingDock = Me.GetLoadingDockFromGUID(loadingdock)
                                newGenericException.objWarehouse = Me.GetWarehouseFromGUID(newGenericException.objLoadingDock.WarehouseID)
                                newGenericException.objRecurrence = recurrence
                                newGenericException.objLoadingDockException = Nothing
                                collGenericExceptions.Add(newGenericException)
                            Next
                        End If
                    End If
                Next
                For Each dockexception As dbiWSF.FrameworkObjects.objLoadingDockException In Me.LoadingDockExceptions
                    If dockexception.StartDate.Date = DateToCheck Or dockexception.EndDate.Date = DateToCheck Then
                        For Each loadingdock As System.Guid In dockexception.LoadingDocks
                            Dim newGenericException As New dbiWSF.FrameworkObjects.objGenericException
                            newGenericException.DateStart = dockexception.StartDate
                            newGenericException.DateEnd = dockexception.EndDate
                            newGenericException.Description = dockexception.Description
                            newGenericException.objLoadingDock = Me.GetLoadingDockFromGUID(loadingdock)
                            newGenericException.objWarehouse = Me.GetWarehouseFromGUID(newGenericException.objLoadingDock.WarehouseID)
                            newGenericException.objRecurrence = Nothing
                            newGenericException.objLoadingDockException = dockexception
                            collGenericExceptions.Add(newGenericException)
                        Next
                    End If
                Next
            Next

            Return collGenericExceptions
        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptions(ByVal DateToCheck As Date) _
                                            As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)
            Dim collDates As New System.Collections.Generic.List(Of Date)
            collDates.Add(DateToCheck)

            Return GetGenericExceptions(collDates)

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptions(ByVal startDate As Date, ByVal endDate As Date) _
                                    As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim DateSpan As New System.Collections.Generic.List(Of Date)
            Dim DateCount As Integer
            Dim CalcStartDate As Date
            Dim CalcEndDate As Date

            If startDate > endDate Then
                CalcEndDate = startDate
                CalcStartDate = endDate
            Else
                CalcEndDate = endDate
                CalcStartDate = startDate
            End If

            For DateCount = 0 To DateDiff(DateInterval.Day, CalcStartDate, CalcEndDate)
                DateSpan.Add(CalcStartDate.AddDays(DateCount))
            Next
            Return GetGenericExceptions(DateSpan)

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given warehouse.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByWhse(ByVal curWarehouse As dbiWSF.FrameworkObjects.objWarehouse, _
                                                   ByVal collDates As System.Collections.Generic.List(Of Date)) _
                                                   As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(collDates)
                If curGenException.objWarehouse.WarehouseID = curWarehouse.WarehouseID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given warehouse.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByWhse(ByVal curWarehouse As dbiWSF.FrameworkObjects.objWarehouse, _
                                                   ByVal DateToCheck As Date) _
                                                   As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(DateToCheck)
                If curGenException.objWarehouse.WarehouseID = curWarehouse.WarehouseID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given warehouse.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByWhse(ByVal curWarehouse As dbiWSF.FrameworkObjects.objWarehouse, _
                                                  ByVal startDate As Date, ByVal endDate As Date) _
                                                  As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(startDate, endDate)
                If curGenException.objWarehouse.WarehouseID = curWarehouse.WarehouseID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given loading dock.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByLoadingDock(ByVal curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock, _
                                                   ByVal collDates As System.Collections.Generic.List(Of Date)) _
                                                   As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(collDates)
                If curGenException.objLoadingDock.LoadingDockID = curLoadingDock.LoadingDockID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given loading dock.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByLoadingDock(ByVal curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock, _
                                                  ByVal DateToCheck As Date) _
                                                  As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(DateToCheck)
                If curGenException.objLoadingDock.LoadingDockID = curLoadingDock.LoadingDockID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function

        ''' <summary>Supporting Method: Gets a collection of generic exceptions for a given loading dock.</summary>
        ''' <remarks>Generic exceptions are a combination of LoadingDockExceptions and Recurrences of RecurrenceObjectType=DockException</remarks>
        ''' <returns>Collection of objGenericException</returns>
        Public Function GetGenericExceptionsByLoadingDock(ByVal curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock, _
                                                          ByVal startDate As Date, ByVal endDate As Date) _
                                                          As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            Dim curGenericExceptions As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objGenericException)

            For Each curGenException As dbiWSF.FrameworkObjects.objGenericException In GetGenericExceptions(startDate, endDate)
                If curGenException.objLoadingDock.LoadingDockID = curLoadingDock.LoadingDockID Then
                    curGenericExceptions.Add(curGenException)
                End If
            Next

            Return curGenericExceptions

        End Function


    End Class

    ''' <summary>
    ''' The basic building block for the WSF. Each Warehouse can contain multiple loading docks.
    ''' </summary>
    ''' <remarks></remarks>
    Public Class objWarehouse
        Private l_WarehouseID As New System.Guid
        Private l_Description As String = WarehouseDescription
        Private l_Location As String = WarehouseLocation
        Private l_LoadingDocksCollection As New System.Collections.Generic.List(Of objLoadingDock)
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = WarehouseNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects

        ''' <summary>The GUID that identifies the warehouse to the databinding class.</summary>
        Public Property WarehouseID() As System.Guid
            Get
                Return l_WarehouseID
            End Get
            Set(ByVal value As System.Guid)
                l_WarehouseID = value
                'If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateWarehouseDataRow(Me)
            End Set
        End Property

        ''' <summary>The description of the warehouse.</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateWarehouseDataRow(Me)
            End Set
        End Property

        ''' <summary>The physical location of the warehouse. Can be an address or other property identifier.</summary>
        Public Property Location() As String
            Get
                Return l_Location
            End Get
            Set(ByVal value As String)
                l_Location = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateWarehouseDataRow(Me)
            End Set
        End Property

        ''' <summary>The collection of loading docks attached to this warehouse.</summary>
        ''' <remarks>The collection is maintained through the databinding class via the LoadingDock object itself,
        '''  therefore there is no direct data maintenance on this collection.</remarks>
        Public Property LoadingDocks() As Collections.Generic.List(Of objLoadingDock)
            Get
                Return l_LoadingDocksCollection
            End Get
            Set(ByVal value As Collections.Generic.List(Of objLoadingDock))
                l_LoadingDocksCollection = value
            End Set
        End Property

        ''' <summary>The datatable.datarow used to generate this warehouse object.</summary>
        ''' <remarks>This is used extensively by the databinding class.</remarks>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application.</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateWarehouseDataRow(Me)
            End Set
        End Property

        ''' <summary>
        ''' Creates a new warehouse object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            'Creates a new warehouseID - <Modify> for other data types
            Me.WarehouseID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary> This method adds the current warehouse object to your database via the databinding class.</summary>
        Public Sub AddNew()
            Me.l_WSFObject.WSFDatabinding.AddNewWarehouse(Me)
        End Sub

        ''' <summary>This method will remove the current warehouse item from your database via the databinding class</summary>
        Public Sub Remove()
            Me.l_WSFObject.Warehouses.Remove(Me)
            Me.l_WSFObject.WSFDatabinding.RemoveWarehouse(Me)
        End Sub

        ''' <summary>
        ''' This method will get the next available Warehouse Ordinal for
        ''' loading docks. This is based on the collection so be sure to update
        ''' your database if you are using manual updates.
        ''' </summary>
        ''' <returns>Long integer value indicating the next available ordinal (one based)</returns>
        ''' <remarks>These ordinals are used in the business rule layer for breakout docks so be sure
        ''' to increment by one or modify the business rule accordingly.</remarks>
        Public Function GetNextLoadingDockWarehouseOrdinal() As Long
            Dim curMax As Long
            For Each curLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock In Me.LoadingDocks
                If curLoadingDock.WarehouseOrdinal > curMax Then
                    curMax = curLoadingDock.WarehouseOrdinal
                End If
            Next
            'By default we increment by one to work with the business rule for breakout docks
            'If you modify this value, be sure to change the business rule or disable it.
            Return curMax + 1
        End Function

    End Class

    ''' <summary>The loading docks house the shipment collections</summary>
    Public Class objLoadingDock
        Private l_LoadingDockID As New System.Guid
        Private l_WarehouseID As System.Guid
        Private l_Description As String = LoadingDockDescription
        Private l_WarehouseOrdinal As Long = LoadingDockWarehouseOrdinal
        Private l_Shipments As New System.Collections.Generic.List(Of objShipment)
        Private l_CargoTypes As New System.Collections.Generic.List(Of System.Guid)
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = LoadingDockNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects

        ''' <summary>The GUID that identifies the loading dock to the databinding class</summary>
        Public Property LoadingDockID() As System.Guid
            Get
                Return l_LoadingDockID
            End Get
            Set(ByVal value As System.Guid)
                l_LoadingDockID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
            End Set
        End Property

        ''' <summary>The warehouse GUID to which this object is attached</summary>
        ''' <remarks>The warehouseID can be an empty GUID indicating that the 
        ''' loading dock is not currently assigned to a warehouse (useful for mobile dock structures
        ''' such as mobile cranes or generic yard locations)</remarks>
        Public Property WarehouseID() As System.Guid
            Get
                Return l_WarehouseID
            End Get
            Set(ByVal value As System.Guid)
                Dim origWarehouseID As System.Guid = l_WarehouseID
                l_WarehouseID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then Me.l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then Me.l_WSFObject.collectionTransferLoadingDock(Me, origWarehouseID, value)
            End Set
        End Property

        ''' <summary>The description of the loading dock</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
            End Set
        End Property

        ''' <summary>A long integer that represents the physical order of the loading docks within the warehouse</summary>
        ''' <remarks>This value is left to the developer to use, we would recommend increments of 100 to 1000 between docks
        ''' as you can then insert docks as needed. This is only an ordinal reference, it is not used in the keys in any way
        ''' as all keys are GUID based. This means you can change these at any point without affecting the data storage class.</remarks>
        Public Property WarehouseOrdinal() As Long
            Get
                Return l_WarehouseOrdinal
            End Get
            Set(ByVal value As Long)
                l_WarehouseOrdinal = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
            End Set
        End Property

        ''' <summary>The collection of shipments that are attached to this loading dock.</summary>
        Public Property Shipments() As System.Collections.Generic.List(Of objShipment)
            Get
                Return l_Shipments
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of objShipment))
                l_Shipments = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
            End Set
        End Property

        ''' <summary>A collection of CargoType GUIDs that this loading dock will accept</summary>
        ''' <remarks>Leave this collection empty to accept all cargo types. 
        ''' The cargoTypes are stored in the <see cref="dbiWSF.FrameworkObjects.objOrderDetail.CargoTypeID"></see></remarks>
        Public Property CargoTypes() As System.Collections.Generic.List(Of System.Guid)
            Get
                Return l_CargoTypes
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of System.Guid))
                l_CargoTypes = value
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this loading dock</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application.</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockDataRow(Me)
            End Set
        End Property

        'TODO:Remove
        Private l_Address As String
        Public Property Address() As String
            Get
                Return l_Address
            End Get
            Set(ByVal value As String)
                l_Address = value
            End Set
        End Property

        ''' <summary>
        ''' Creates a new loading dock object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_LoadingDockID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objWarehouse.LoadingDocks"></see></remarks>
        Public Sub AddNew()
            Me.l_WSFObject.WSFDatabinding.AddNewLoadingDock(Me)
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class and adds the loadingdock object
        ''' to the supplied warehouse's LoadingDocks collection.
        ''' </summary>
        ''' <param name="Warehouse">The warehouse object to add the loading dock to.</param>
        ''' <remarks></remarks>
        Public Sub AddNew(ByRef Warehouse As dbiWSF.FrameworkObjects.objWarehouse)
            Try
                Me.AddNew()
                Warehouse.LoadingDocks.Add(Me)
            Catch ex As Exception
                Throw New Exception("Warehouse collection add new LoadingDock error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' This method removes the loading dock from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objWarehouse.LoadingDocks"></see></remarks>
        Public Sub Remove()
            Me.l_WSFObject.WSFDatabinding.RemoveLoadingDock(Me)
        End Sub

        ''' <summary>
        ''' This method removes the loading dock from the database through the databinding class as well
        ''' as removing the loading dock object from the <see cref="dbiWSF.FrameworkObjects.objWarehouse.LoadingDocks"></see>
        ''' </summary>
        ''' <param name="Warehouse">The warehouse object to remove the loading dock from</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef Warehouse As dbiWSF.FrameworkObjects.objWarehouse)
            Try
                Me.Remove()
                Warehouse.LoadingDocks.Remove(Me)
            Catch ex As Exception
                Throw New Exception("Warehouse collection remove LoadingDock error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' This method removes a CargoType from the loading dock.
        ''' </summary>
        ''' <param name="CargoTypeID">The System.Guid ID of the CargoType to remove.</param>
        ''' <remarks></remarks>
        Public Sub RemoveCargoType(ByRef CargoTypeID As System.Guid)
            Try
                Me.l_WSFObject.WSFDatabinding.RemoveLoadingDockCargoKey(CargoTypeID, Me)
                Me.CargoTypes.Remove(CargoTypeID)
            Catch ex As Exception
                Throw New Exception("LoadingDockKey Removal Error", ex) '<Generic Error>
            End Try


        End Sub

        ''' <summary>
        ''' Adds a specific CargoType to the loading dock.
        ''' </summary>
        ''' <param name="CargoTypeID">The System.GUID ID for the CargoType to add.</param>
        ''' <remarks></remarks>
        Public Sub AddCargoType(ByRef CargoTypeID As System.Guid)
            Try

                If Not (Me.CargoTypes.Contains(CargoTypeID)) Then
                    Me.l_WSFObject.WSFDatabinding.AddLoadingDockCargoKey(CargoTypeID, Me)
                    Me.CargoTypes.Add(CargoTypeID)
                End If
            Catch ex As Exception
                Throw New Exception("LoadingDockKey Add Error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' Adds a collection of CargoType ID's to the loading dock.
        ''' </summary>
        ''' <param name="CargoTypeIDs">A collection of System.GUIDs for the CargoTypes to add.</param>
        ''' <remarks></remarks>
        Public Sub AddCargoTypes(ByRef CargoTypeIDs As System.Collections.Generic.List(Of System.Guid))
            For Each curCargoID As System.Guid In CargoTypeIDs
                AddCargoType(curCargoID)
            Next
        End Sub

        ''' <summary>Clears all CargoType GUIDs from the loading dock.</summary>
        Public Sub ClearCargoTypes()
            Me.CargoTypes.Clear()
            Me.l_WSFObject.WSFDatabinding.ClearCargoTypesFromLoadingDock(Me)
        End Sub
    End Class

    ''' <summary>The shipments contain the order headers and scheduled Start/End times of the shipment carriers</summary>
    Public Class objShipment
        Private l_ShipmentID As System.Guid
        Private l_LoadingDockID As System.Guid
        Private l_Description As String = ShipmentDescription
        Private l_SchedStartTime As Date
        Private l_SchedEndTime As Date
        Private l_ShipmentType As ShipmentTypes = ShipmentType
        Private l_BreakoutDockQty As Long = ShipmentBreakoutQty
        Private l_EquipmentID As String = ShipmentEquipmentID
        Private l_CarrierID As String = ShipmentCarrierID
        Private l_Priority As Integer = ShipmentPriority
        Private l_OrderHeaders As New System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objOrderHeader)
        Private l_Notes As String = ShipmentNotes
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects


        ''' <summary>The GUID that identifies the shipment to the databinding class</summary>
        Public Property ShipmentID() As System.Guid
            Get
                Return l_ShipmentID
            End Get
            Set(ByVal value As System.Guid)
                l_ShipmentID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The loading dock GUID to which this object is attached</summary>
        ''' <remarks>The LoadingDockID can be an empty GUID indicating that the 
        ''' shipment is not currently assigned to a loading dock</remarks>
        Public Property LoadingDockID() As System.Guid
            Get
                Return l_LoadingDockID
            End Get
            Set(ByVal value As System.Guid)
                If l_LoadingDockID <> value Then
                    Dim OrigLoadingDockID As System.Guid = l_LoadingDockID
                    l_LoadingDockID = value
                    If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
                    If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then Me.l_WSFObject.WSFDatabinding.WSFObjects.collectionTransferShipment(Me, OrigLoadingDockID, value)
                End If
            End Set
        End Property

        ''' <summary>The shipment description</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The scheduled start time of the shipment</summary>
        Public Property SchedStartTime() As Date
            Get
                Return l_SchedStartTime
            End Get
            Set(ByVal value As Date)
                If l_SchedStartTime <> value Then
                    l_SchedStartTime = value
                    If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
                End If
            End Set
        End Property

        ''' <summary>The scheduled end time of the shipment</summary>
        Public Property SchedEndTime() As Date
            Get
                Return l_SchedEndTime
            End Get
            Set(ByVal value As Date)
                If l_SchedEndTime <> value Then
                    l_SchedEndTime = value
                    If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
                End If
            End Set
        End Property

        ''' <summary>Determines the type of shipment (inbound/outbound)</summary>
        Public Property ShipmentType() As ShipmentTypes
            Get
                Return l_ShipmentType
            End Get
            Set(ByVal value As ShipmentTypes)
                l_ShipmentType = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The number of loading docks above a single loading dock needed to breakout a shipment</summary>
        ''' <remarks>If you only need a single loading dock to receive or load a shipment then this value would be 0. 
        ''' However if you need 2 docks to break down a shipment before warehousing the goods, then this value would be 1.</remarks>
        Public Property BreakoutDockQty() As Long
            Get
                Return l_BreakoutDockQty
            End Get
            Set(ByVal value As Long)
                l_BreakoutDockQty = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The equipment ID is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary purpose is for items like trailer ID numbers or railway car IDs</remarks>
        Public Property EquipmentID() As String
            Get
                Return l_EquipmentID
            End Get
            Set(ByVal value As String)
                l_EquipmentID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The carrier ID is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary purpose is for storing Vendor/Shipping company numbers</remarks>
        Public Property CarrierID() As String
            Get
                Return l_CarrierID
            End Get
            Set(ByVal value As String)
                l_CarrierID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The priority is an integer value that can be used in complex scheduling algorithms</summary>
        Public Property Priority() As Integer
            Get
                Return l_Priority
            End Get
            Set(ByVal value As Integer)
                l_Priority = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
            End Set
        End Property

        ''' <summary>The collection of order headers that are attached to this shipment</summary>
        Public Property OrderHeaders() As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objOrderHeader)
            Get
                Return l_OrderHeaders
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of dbiWSF.FrameworkObjects.objOrderHeader))
                l_OrderHeaders = value
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this shipment</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application.</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                If l_Notes <> value Then
                    l_Notes = value
                    If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateShipmentDataRow(Me)
                End If
            End Set
        End Property

        ''' <summary>
        ''' Creates a new shipment object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_ShipmentID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objLoadingDock.Shipments"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewShipment(Me)
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class and adds the shipment object
        ''' to the supplied loadingdock.shipments collection.
        ''' </summary>
        ''' <param name="LoadingDock">The loading dock to add the shipment to</param>
        ''' <remarks></remarks>
        Public Sub AddNew(ByRef LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock)
            Try
                Me.AddNew()
                LoadingDock.Shipments.Add(Me)
            Catch ex As Exception
                Throw New Exception("Loading dock add new shipment collection error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' This method removes the shipment from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objLoadingDock.Shipments"></see></remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveShipment(Me)
        End Sub

        ''' <summary>
        ''' This method removes the shipment from the database through the databinding class as well
        ''' as removing the shipment object from the <see cref="dbiWSF.FrameworkObjects.objLoadingDock.Shipments"></see>
        ''' </summary>
        ''' <param name="LoadingDock">The loading dock object to remove the shipment from</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef LoadingDock As dbiWSF.FrameworkObjects.objLoadingDock)
            Try
                Me.Remove()
                LoadingDock.Shipments.Remove(Me)
            Catch ex As Exception
                Throw New Exception("Loading dock collection shipment removal error", ex) '<Generic Error>
            End Try

        End Sub

        ''' <summary>
        ''' This method returns a collection of System.GUIDs that represent
        ''' the CargoTypes that are on this shipment.
        ''' </summary>
        ''' <returns>Collection of System.GUIDs</returns>
        ''' <remarks></remarks>
        Public Function GetCargoTypes() As System.Collections.Generic.List(Of System.Guid)
            Dim collCargoTypes As New System.Collections.Generic.List(Of System.Guid)

            Dim linqGetCargo = From curOrderHeader As dbiWSF.FrameworkObjects.objOrderHeader In Me.OrderHeaders _
                               From curOrderDetail As dbiWSF.FrameworkObjects.objOrderDetail In curOrderHeader.OrderDetails _
                               Select curOrderDetail

            For Each curDetail As dbiWSF.FrameworkObjects.objOrderDetail In linqGetCargo
                If Not collCargoTypes.Contains(curDetail.CargoTypeID) Then
                    collCargoTypes.Add(curDetail.CargoTypeID)
                End If
            Next
            Return collCargoTypes
        End Function

    End Class

    ''' <summary>The order header provides an integration point to external POS/Order management systems. 
    ''' The order header also houses the order details objects as well as other integration properties</summary>
    Public Class objOrderHeader
        Private l_OrderID As System.Guid
        Private l_ShipmentID As System.Guid
        Private l_OrderEntryID As String = OrderHeaderEntryID
        Private l_OrderEntryType As String = OrderHeaderEntryType
        Private l_VendorID As String = OrderHeaderVendorID
        Private l_CustomerID As String = OrderHeaderCustomerID
        Private l_OrderDetails As New System.Collections.Generic.List(Of objOrderDetail)
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = OrderHeaderNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects

        ''' <summary>The GUID that identifies the order header to the databinding class</summary>
        Public Property OrderID() As System.Guid
            Get
                Return l_OrderID
            End Get
            Set(ByVal value As System.Guid)
                l_OrderID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>The shipment GUID to which this object is attached</summary>
        ''' <remarks>The ShipmentID can be an empty GUID indicating that the 
        ''' order header is not currently assigned to a shipment</remarks>
        Public Property ShipmentID() As System.Guid
            Get
                Return l_ShipmentID
            End Get
            Set(ByVal value As System.Guid)
                Dim origShipmentID As System.Guid = l_ShipmentID
                l_ShipmentID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.WSFObjects.collectionTransferOrderHeader(Me, origShipmentID, value)
            End Set
        End Property

        ''' <summary>The order entry ID is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary integration for this is into a POS/Order Entry system</remarks>
        Public Property OrderEntryID() As String
            Get
                Return l_OrderEntryID
            End Get
            Set(ByVal value As String)
                l_OrderEntryID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>The order entry type is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary purpose is for tracking the type of order (cargo manifest/delivery order/packing slip)</remarks>
        Public Property OrderEntryType() As String
            Get
                Return l_OrderEntryType
            End Get
            Set(ByVal value As String)
                l_OrderEntryType = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>The vendor ID is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary purpose is for tracking vendor ID of the order</remarks>
        Public Property VendorID() As String
            Get
                Return l_VendorID
            End Get
            Set(ByVal value As String)
                l_VendorID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>The customer ID is used for external integration or for reporting.</summary>
        ''' <remarks>This value is not used to index any databinding. As such it can be modified as needed.
        ''' The primary purpose is for tracking customer ID of the order</remarks>
        Public Property CustomerID() As String
            Get
                Return l_CustomerID
            End Get
            Set(ByVal value As String)
                l_CustomerID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>The collection of order details</summary>
        ''' <remarks>These can be linked to external applications for line numbers, picking list items, item SKUs etc.</remarks>
        Public Property OrderDetails() As System.Collections.Generic.List(Of objOrderDetail)
            Get
                Return l_OrderDetails
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of objOrderDetail))
                l_OrderDetails = value
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this order header</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application.</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderHeaderDataRow(Me)
            End Set
        End Property

        ''' <summary>
        ''' Creates a new order header object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_OrderID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objShipment.OrderHeaders"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewOrderHeader(Me)
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class and adds the order header object
        ''' to the supplied shipments.orderheaders collection.
        ''' </summary>
        ''' <param name="Shipment">The shipment to add the order header to</param>
        ''' <remarks></remarks>
        Public Sub AddNew(ByRef Shipment As dbiWSF.FrameworkObjects.objShipment)
            Try
                Me.AddNew()
                Shipment.OrderHeaders.Add(Me)
            Catch ex As Exception
                Throw New Exception("Shipment collection add new OrderHeader error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' This method removes the order header from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objShipment.OrderHeaders"></see></remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveOrderHeader(Me)
        End Sub

        ''' <summary>
        ''' This method removes the order header from the database through the databinding class as well
        ''' as removing the order header object from the <see cref="dbiWSF.FrameworkObjects.objShipment.OrderHeaders"></see>
        ''' </summary>
        ''' <param name="Shipment">The shipment object to remove the order header from</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef Shipment As dbiWSF.FrameworkObjects.objShipment)
            Try
                Me.Remove()
                Shipment.OrderHeaders.Remove(Me)
            Catch ex As Exception
                Throw New Exception("Shipment collection remove OrderHeader error", ex) '<Generic Error>
            End Try
        End Sub
    End Class

    ''' <summary>The order detail is the final object in the chain, it contains integration points to other applications</summary>
    Public Class objOrderDetail
        Private l_OrderDetailID As System.Guid
        Private l_OrderID As System.Guid
        Private l_LineNumber As Long = OrderDetailLineNumber
        Private l_CargoTypeID As System.Guid
        Private l_UnitWeight As String = OrderDetailUnitWeight
        Private l_UnitOfMeasure As String = OrderDetailUnitOfMeasure
        Private l_UnitVolume As String = OrderDetailUnitVolume
        Private l_Quantity As Double = OrderDetailQuantity
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = OrderDetailNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects


        ''' <summary>The GUID that identifies the order detail to the databinding class</summary>
        Public Property OrderDetailID() As System.Guid
            Get
                Return l_OrderDetailID
            End Get
            Set(ByVal value As System.Guid)
                l_OrderDetailID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>The order header GUID to which this object is attached</summary>
        ''' <remarks>The OrderID can be an empty GUID indicating that the 
        ''' order detail is not currently assigned to an order header</remarks>
        Public Property OrderID() As System.Guid
            Get
                Return l_OrderID
            End Get
            Set(ByVal value As System.Guid)
                l_OrderID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>The physical line number of the order detail</summary>
        ''' <remarks>This is usually generated by a POS/Order Entry system but can be modified as needed</remarks>
        Public Property LineNumber() As Long
            Get
                Return l_LineNumber
            End Get
            Set(ByVal value As Long)
                l_LineNumber = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>The cargo type GUID to which this shipment belongs</summary>
        ''' <remarks>The CargoType ID can be an empty GUID indicating that the 
        ''' order detail does not have a CargoType attached to it</remarks>
        Public Property CargoTypeID() As System.Guid
            Get
                Return l_CargoTypeID
            End Get
            Set(ByVal value As System.Guid)
                l_CargoTypeID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>Used for integration to external apps</summary>
        Public Property UnitWeight() As String
            Get
                Return l_UnitWeight
            End Get
            Set(ByVal value As String)
                l_UnitWeight = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>Used for integration to external apps</summary>
        Public Property UnitOfMeasure() As String
            Get
                Return l_UnitOfMeasure
            End Get
            Set(ByVal value As String)
                l_UnitOfMeasure = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>Used for integration to external apps</summary>
        Public Property UnitVolume() As String
            Get
                Return l_UnitVolume
            End Get
            Set(ByVal value As String)
                l_UnitVolume = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>Used for integration to external apps</summary>
        Public Property Quantity() As Double
            Get
                Return l_Quantity
            End Get
            Set(ByVal value As Double)
                l_Quantity = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this order detail</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application.</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateOrderDetailDataRow(Me)
            End Set
        End Property

        ''' <summary>
        ''' Creates a new order detail object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_OrderDetailID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objOrderHeader.OrderDetails"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewOrderDetail(Me)
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class and adds the order detail object
        ''' to the supplied OrderHeader.OrderDetails collection.
        ''' </summary>
        ''' <param name="OrderHeader">The OrderHeader to add the order detail to</param>
        ''' <remarks></remarks>
        Public Sub AddNew(ByRef OrderHeader As dbiWSF.FrameworkObjects.objOrderHeader)
            Try
                Me.AddNew()
                OrderHeader.OrderDetails.Add(Me)
            Catch ex As Exception
                Throw New Exception("Order Header collection add new OrderDetail error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>
        ''' This method removes the order detail from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objOrderHeader.OrderDetails"></see></remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveOrderDetail(Me)
        End Sub

        ''' <summary>
        ''' This method removes the order detail from the database through the databinding class as well
        ''' as removing the order detail object from the <see cref= "dbiWSF.FrameworkObjects.objOrderHeader.OrderDetails"></see>
        ''' </summary>
        ''' <param name="OrderHeader">The order header object to remove the order detail from</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef OrderHeader As dbiWSF.FrameworkObjects.objOrderHeader)
            Try
                Me.Remove()
                OrderHeader.OrderDetails.Remove(Me)
            Catch ex As Exception
                Throw New Exception("OrderHeader Detail collection remove OrderDetail error", ex) '<Generic Error>
            End Try
        End Sub

    End Class

#End Region

#Region "--Supporting Objects--"
    ''' <summary>Creates a recurrence object that can be used to create recurring items</summary>
    ''' <remarks>The framework currently ships with recurrence being used for exceptions
    ''' but the method for working with recurring shipments would be similar</remarks>
    Public Class objRecurrence
        Private l_RecurrenceID As System.Guid
        Private l_RecurringStartDate As Date
        Private l_RecurringEndDate As Date
        Private l_ObjectStartDate As Date
        Private l_ObjectEndDate As Date
        Private l_ObjectType As RecurrenceObjectType = RecurrenceType
        Private l_Description As String = RecurrenceDescription
        Private l_RecurrenceType As RecurrenceTypes
        Private l_Frequency As Integer = 1
        Private l_DaysOfWeek() As Byte
        Private l_CustomDates As New Collections.Generic.List(Of Date)
        Private l_RecurringObjects As New System.Collections.Generic.List(Of System.Guid)
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = RecurrenceNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects


        ''' <summary>The GUID that identifies the recurrence object to the databinding class</summary>
        Public Property RecurrenceID() As System.Guid
            Get
                Return l_RecurrenceID
            End Get
            Set(ByVal value As System.Guid)
                l_RecurrenceID = value
            End Set
        End Property

        ''' <summary>The date that the recurrence will start on</summary>
        Public Property RecurringStartDate() As Date
            Get
                Return l_RecurringStartDate
            End Get
            Set(ByVal value As Date)
                l_RecurringStartDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The date that the recurrence will end on</summary>
        Public Property RecurringEndDate() As Date
            Get
                Return l_RecurringEndDate
            End Get
            Set(ByVal value As Date)
                l_RecurringEndDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The actual start date and time of the recurring object</summary>
        Public Property ObjectStartDate() As Date
            Get
                Return l_ObjectStartDate
            End Get
            Set(ByVal value As Date)
                l_ObjectStartDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The actual end date and time of the recurring object</summary>
        Public Property ObjectEndDate() As Date
            Get
                Return l_ObjectEndDate
            End Get
            Set(ByVal value As Date)
                l_ObjectEndDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The type of the recurrence object</summary>
        Public Property ObjectType() As RecurrenceObjectType
            Get
                Return l_ObjectType
            End Get
            Set(ByVal value As RecurrenceObjectType)
                l_ObjectType = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The description of the recurrence for reference</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>The type of the recurrence</summary>
        Public Property RecurrenceType() As RecurrenceTypes
            Get
                Return l_RecurrenceType
            End Get
            Set(ByVal value As RecurrenceTypes)
                l_RecurrenceType = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set

        End Property

        ''' <summary>The frequency on which the object occurs</summary>
        Public Property Frequency() As Integer
            Get
                Return l_Frequency
            End Get
            Set(ByVal value As Integer)
                l_Frequency = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>An array of bytes indicating the days of the week on which a weekly recurrence will occur</summary>
        ''' <remarks>This array is based on the System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek
        ''' that is set on the application
        ''' </remarks>
        Public Property DaysOfWeek() As Byte()
            Get
                Return l_DaysOfWeek

            End Get
            Set(ByVal value As Byte())
                l_DaysOfWeek = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>A collection of dates to occur on</summary>
        Public Property CustomDates() As System.Collections.Generic.List(Of Date)
            Get
                Return l_CustomDates
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of Date))
                l_CustomDates = value
            End Set
        End Property

        ''' <summary>A collection of GUIDs on which objects this recurrence will act upon</summary>
        ''' <remarks>By default the framework ships with LoadingDockExceptions enabled so this would be a collection
        ''' of loading dock ID GUIDs to which this recurrence object will apply</remarks>
        Public Property RecurringObjects() As System.Collections.Generic.List(Of System.Guid)
            Get
                Return l_RecurringObjects
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of System.Guid))
                l_RecurringObjects = value
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this recurrence</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateRecurrenceDataRow(Me)
            End Set
        End Property

        ''' <summary>
        ''' Creates a new recurrence object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_RecurrenceID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.Recurrences"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewRecurrence(Me)
            Me.l_WSFObject.Recurrences.Add(Me)
        End Sub

        ''' <summary>
        ''' This method removes the recurrence object from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.Recurrences"></see>
        ''' </remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveRecurrence(Me)
        End Sub

        ''' <summary>
        ''' This method removes the recurrence object from the database and removes the recurrence
        ''' object from the MainWSFObjects.Recurrences collection 
        ''' </summary>
        ''' <param name="MainWSFObjects">The project's main dbiWSFObjects</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef MainWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Try
                Me.Remove()
                MainWSFObjects.Recurrences.Remove(Me)
            Catch ex As Exception
                Throw New Exception("Recurrence object removal error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>This method removes all the recurrence objects on a specific recurrence object and deletes them from the database</summary>
        Public Sub ClearObjects()
            Me.RecurringObjects.Clear()
            l_WSFObject.WSFDatabinding.ClearObjectsFromRecurrence(Me)
        End Sub

        ''' <summary>Adds recurrence objects to the recurring object collection and adds them to the database</summary>
        ''' <param name="RecurranceObjectIDs">A collection of GUIDs representing the objects to which this recurrence applies</param>
        Public Sub AddRecurrenceObjects(ByVal RecurranceObjectIDs As System.Collections.Generic.List(Of System.Guid))
            Me.RecurringObjects.AddRange(RecurranceObjectIDs)
            l_WSFObject.WSFDatabinding.AddObjectsToRecurrence(Me, RecurranceObjectIDs)
        End Sub

        ''' <summary>
        ''' Add a single loading dock to an exception using the Loading Dock ID (GUID)
        ''' </summary>
        ''' <param name="RecurrenceObjectID">The recurrence object (loading dock ID) GUID</param>
        ''' <remarks></remarks>
        Public Sub AddRecurrenceObject(ByVal RecurrenceObjectID As System.Guid)
            If Not Me.RecurringObjects.Contains(RecurrenceObjectID) Then
                Me.RecurringObjects.Add(RecurrenceObjectID)
                l_WSFObject.WSFDatabinding.AddObjectsToRecurrence(Me, Me.RecurringObjects)
            End If
        End Sub

        ''' <summary>
        ''' Removes a single object from the recurrence.
        ''' </summary>
        ''' <param name="RecurrenceObjectID">The object guid to remove.</param>
        Public Sub RemoveObject(ByVal RecurrenceObjectID As System.Guid)
            If Me.RecurringObjects.Contains(RecurrenceObjectID) Then
                Me.RecurringObjects.Remove(RecurrenceObjectID)
                l_WSFObject.WSFDatabinding.RemoveRecurrenceObjectFromRecurrence(RecurrenceObjectID, Me)
            End If
        End Sub

        ''' <summary>
        ''' Returns a collection of date/time values based on the frequency, recurrence type
        ''' and/or daysofweek/custom dates.
        ''' </summary>
        ''' <returns>Collection of Dates</returns>
        ''' <remarks></remarks>
        Public Function GetRecurrenceDates() As System.Collections.Generic.List(Of Date)
            Dim collDates As New System.Collections.Generic.List(Of Date)
            collDates.Clear()

            Select Case Me.RecurrenceType
                Case dbiWSF.FrameworkObjects.RecurrenceTypes.Daily
                    Dim spanDays As Long = DateDiff(DateInterval.Day, Me.RecurringStartDate, Me.RecurringEndDate)

                    For curDay As Long = 0 To spanDays Step Me.Frequency
                        Dim nowDate As Date = Me.RecurringStartDate.AddDays(curDay)
                        collDates.Add(nowDate.Date)
                    Next
                Case dbiWSF.FrameworkObjects.RecurrenceTypes.Monthly
                    Dim spanMonth As Long = DateDiff(DateInterval.Month, Me.RecurringStartDate, Me.RecurringEndDate)

                    For curMonth As Long = 0 To spanMonth Step Me.Frequency
                        Dim nowDate As Date = Me.RecurringStartDate.AddMonths(curMonth)
                        collDates.Add(nowDate.Date)
                    Next
                Case dbiWSF.FrameworkObjects.RecurrenceTypes.Weekly
                    collDates = l_WSFObject.FixedDates(Me.RecurringStartDate, Me.RecurringEndDate, Me.Frequency, Me.DaysOfWeek)
          
                Case dbiWSF.FrameworkObjects.RecurrenceTypes.Custom
                    collDates = Me.CustomDates

            End Select
            Return collDates
        End Function
    End Class

    ''' <summary>The loading dock exceptions can be used to block off an individual loading dock
    '''  or groups of loading docks for a specified time frame</summary>
    Public Class objLoadingDockException
        Private l_LoadingDockExceptionID As System.Guid
        Private l_StartDate As Date
        Private l_EndDate As Date
        Private l_Description As String = LDEDescription
        Private l_LoadingDocks As New System.Collections.Generic.List(Of System.Guid)
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = LDENotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects

        ''' <summary>The GUID that identifies the loading dock exception object to the databinding class</summary>
        Public Property LoadingDockExceptionID() As System.Guid
            Get
                Return l_LoadingDockExceptionID
            End Get
            Set(ByVal value As System.Guid)
                l_LoadingDockExceptionID = value
            End Set
        End Property

        ''' <summary>The date and time to start the exception</summary>
        Public Property StartDate() As Date
            Get
                Return l_StartDate
            End Get
            Set(ByVal value As Date)
                l_StartDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockExceptionDataRow(Me)
            End Set
        End Property

        ''' <summary>The date and time to end the exception</summary>
        Public Property EndDate() As Date
            Get
                Return l_EndDate
            End Get
            Set(ByVal value As Date)
                l_EndDate = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockExceptionDataRow(Me)
            End Set
        End Property

        ''' <summary>A visible description of the exception</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockExceptionDataRow(Me)
            End Set
        End Property

        ''' <summary>A collection of loading docks to which this specific exception will apply</summary>
        Public Property LoadingDocks() As System.Collections.Generic.List(Of System.Guid)
            Get
                Return l_LoadingDocks
            End Get
            Set(ByVal value As System.Collections.Generic.List(Of System.Guid))
                l_LoadingDocks = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockExceptionDataRow(Me)
            End Set
        End Property

        ''' <summary>General notes that can be used in the application</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateLoadingDockExceptionDataRow(Me)
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this exception</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>
        ''' Creates a new recurrence object.
        ''' </summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_LoadingDockExceptionID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.LoadingDockExceptions"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewLoadingDockException(Me)
            Me.l_WSFObject.LoadingDockExceptions.Add(Me)
        End Sub

        ''' <summary>
        ''' This method removes the loading dock exception from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.Recurrences"></see>
        ''' </remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveLoadingDockException(Me)
        End Sub

        ''' <summary>
        ''' This method removes the loading dock exception object from the database and removes the 
        ''' loading dock exception object from the MainWSFObjects.LoadingDockExceptions collection 
        ''' </summary>
        ''' <param name="MainWSFObjects">The project's main dbiWSFObjects</param>
        ''' <remarks></remarks>
        Public Sub Remove(ByRef MainWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Try
                Me.Remove()
                MainWSFObjects.LoadingDockExceptions.Remove(Me)
            Catch ex As Exception
                Throw New Exception("Loading Dock Exceptions removal error", ex) '<Generic Error>
            End Try
        End Sub

        ''' <summary>This method removes all the loading docks on a specific exception object and deletes them from the database</summary>
        Public Sub ClearLoadingDocks()
            Me.LoadingDocks.Clear()
            l_WSFObject.WSFDatabinding.ClearLoadingDocksFromException(Me)
        End Sub

        ''' <summary>Adds the loading docks to the collection on the loading dock exception and adds them to the database</summary>
        ''' <param name="LoadingDockIDs">A collection of GUIDs representing the loading docks to which this exception applies</param>
        Public Sub AddLoadingDocks(ByVal LoadingDockIDs As System.Collections.Generic.List(Of System.Guid))
            Me.LoadingDocks.AddRange(LoadingDockIDs)
            l_WSFObject.WSFDatabinding.AddLoadingDocksToException(Me, LoadingDockIDs)
        End Sub

        ''' <summary>
        ''' Add a single loading dock to an exception using the Loading Dock ID (GUID)
        ''' </summary>
        ''' <param name="LoadingDockID">The loading dock ID GUID</param>
        ''' <remarks></remarks>
        Public Sub AddLoadingDock(ByVal LoadingDockID As System.Guid)
            If Not Me.LoadingDocks.Contains(LoadingDockID) Then
                Me.LoadingDocks.Add(LoadingDockID)
                l_WSFObject.WSFDatabinding.AddLoadingDocksToException(Me, Me.LoadingDocks)
            End If
        End Sub

        ''' <summary>
        ''' Remove a single loading dock from an exception.
        ''' </summary>
        ''' <param name="LoadingDockID">The loading dock guid to remove.</param>
        ''' <remarks></remarks>
        Public Sub RemoveLoadingDock(ByVal LoadingDockID As System.Guid)
            If Me.LoadingDocks.Contains(LoadingDockID) Then
                Me.LoadingDocks.Remove(LoadingDockID)
                l_WSFObject.WSFDatabinding.RemoveLoadingDockFromException(LoadingDockID, Me)
            End If
        End Sub
    End Class

    ''' <summary>The cargo types indicate the type of cargo on the detail line. These objects are used globally and referenced by GUID
    ''' in the <see cref="dbiWSF.FrameworkObjects.objOrderDetail.CargoTypeID"></see></summary>
    Public Class objCargoType
        Private l_CargoID As System.Guid
        Private l_Description As String = CargoTypeDescription
        Private l_Icon As Object
        Private l_DataRow As DataRow
        Private l_Tag As Object
        Private l_Notes As String = CargoTypeNotes
        Private l_WSFObject As dbiWSF.FrameworkObjects.objWSFObjects

        ''' <summary>The GUID that identifies the cargo type object to the databinding class</summary>
        Public Property CargoID() As System.Guid
            Get
                Return l_CargoID
            End Get
            Set(ByVal value As System.Guid)
                l_CargoID = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateCargoTypeDataRow(Me)
            End Set
        End Property

        ''' <summary>A description of the cargo type</summary>
        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateCargoTypeDataRow(Me)
            End Set
        End Property

        ''' <summary>An object that can be used to house an icon or other graphic object</summary>
        ''' <remarks>At the data level this is stored and transferred as a blob (array of bytes)</remarks>
        Public Property Icon() As Object
            Get
                Return l_Icon
            End Get
            Set(ByVal value As Object)
                l_Icon = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateCargoTypeDataRow(Me)
            End Set
        End Property

        ''' <summary>The database.datarow used in the databinding to create this cargo type</summary>
        Public Property AttachedDataRow() As DataRow
            Get
                Return l_DataRow
            End Get
            Set(ByVal value As DataRow)
                l_DataRow = value
            End Set
        End Property

        ''' <summary>A generic object that can be used as needed.</summary>
        ''' <remarks>This property is not maintained by the databinding class.</remarks>
        Public Property Tag() As Object
            Get
                Return l_Tag
            End Get
            Set(ByVal value As Object)
                l_Tag = value
            End Set
        End Property

        ''' <summary>General notes that can be used in the application</summary>
        Public Property Notes() As String
            Get
                Return l_Notes
            End Get
            Set(ByVal value As String)
                l_Notes = value
                If Not Me.l_WSFObject.WSFDatabinding.IsLoadingData Then l_WSFObject.WSFDatabinding.UpdateCargoTypeDataRow(Me)
            End Set
        End Property

        ''' <summary>Creates a new cargo type object</summary>
        ''' <param name="objWSFObjects">The base WSFObjects from your code class</param>
        Public Sub New(ByRef objWSFObjects As dbiWSF.FrameworkObjects.objWSFObjects)
            Me.l_CargoID = System.Guid.NewGuid
            Me.l_WSFObject = objWSFObjects
        End Sub

        ''' <summary>
        ''' This method adds a new record to the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can add your object directly to the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.CargoTypes"></see></remarks>
        Public Sub AddNew()
            l_WSFObject.WSFDatabinding.AddNewCargoType(Me)
            Me.l_WSFObject.CargoTypes.Add(Me.Description, Me)
        End Sub

        ''' <summary>
        ''' This method removes the cargotype object from the database through the databinding class
        ''' </summary>
        ''' <remarks>If you aren't using the databinding class you do not need to use this method
        ''' You can remove your object directly through the <see cref="dbiWSF.FrameworkObjects.objWSFObjects.CargoTypes"></see>
        ''' </remarks>
        Public Sub Remove()
            l_WSFObject.WSFDatabinding.RemoveCargoType(Me)
        End Sub

    End Class

    ''' <summary>An object used to normalize both exceptions and recurring exceptions
    ''' into a single flat collection</summary>
    Public Class objGenericException
        Private l_GenericID As System.Guid
        Private l_DateStart As Date
        Private l_DateEnd As Date
        Private l_Description As String
        Private l_objWarehouse As dbiWSF.FrameworkObjects.objWarehouse
        Private l_objLoadingDock As dbiWSF.FrameworkObjects.objLoadingDock
        Private l_objRecurrence As dbiWSF.FrameworkObjects.objRecurrence
        Private l_objLoadingDockException As dbiWSF.FrameworkObjects.objLoadingDockException

        Public Property GenericID() As System.Guid
            Get
                Return l_GenericID
            End Get
            Set(ByVal value As System.Guid)
                l_GenericID = value
            End Set
        End Property

        Public Property DateStart() As Date
            Get
                Return l_DateStart
            End Get
            Set(ByVal value As Date)
                l_DateStart = value
            End Set
        End Property

        Public Property DateEnd() As Date
            Get
                Return l_DateEnd
            End Get
            Set(ByVal value As Date)
                l_DateEnd = value
            End Set
        End Property

        Public Property Description() As String
            Get
                Return l_Description
            End Get
            Set(ByVal value As String)
                l_Description = value
            End Set
        End Property
        Public Property objWarehouse() As dbiWSF.FrameworkObjects.objWarehouse
            Get
                Return l_objWarehouse
            End Get
            Set(ByVal value As dbiWSF.FrameworkObjects.objWarehouse)
                l_objWarehouse = value
            End Set
        End Property

        Public Property objLoadingDock() As dbiWSF.FrameworkObjects.objLoadingDock
            Get
                Return l_objLoadingDock
            End Get
            Set(ByVal value As dbiWSF.FrameworkObjects.objLoadingDock)
                l_objLoadingDock = value
            End Set
        End Property

        Public Property objRecurrence() As dbiWSF.FrameworkObjects.objRecurrence
            Get
                Return l_objRecurrence
            End Get
            Set(ByVal value As dbiWSF.FrameworkObjects.objRecurrence)
                l_objRecurrence = value
            End Set
        End Property

        Public Property objLoadingDockException() As dbiWSF.FrameworkObjects.objLoadingDockException
            Get
                Return l_objLoadingDockException
            End Get
            Set(ByVal value As dbiWSF.FrameworkObjects.objLoadingDockException)
                l_objLoadingDockException = value
            End Set
        End Property

        Public Sub New()
            MyBase.New()
            Me.GenericID = System.Guid.NewGuid()
        End Sub
    End Class
#End Region

#End Region

End Class